package com.yunxi.controller.sell;

import com.yunxi.core.web.ApiResult;
import com.yunxi.core.web.CurrentUser;
import com.yunxi.core.web.LoginInfo;
import com.yunxi.core.web.ResponseUtil;
import com.yunxi.sell.pojo.CarSellPartnerSaveReqVO;
import com.yunxi.sell.pojo.CarSellPartnerQueryReqVO;
import com.yunxi.sell.pojo.CarSellPartnerSetAppStatusReqVO;
import com.yunxi.sell.service.CarSellPartnerDubboService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 车辆销售渠道管理 前端控制器
 * </p>
 *
 * @author 
 * @since 2019-08-21
 */
@RestController
@RequestMapping("/admin/carsellpartner")
@Api(tags = "pms:carsellpartner", description = "车辆销售渠道管理接口")
public class CarSellPartnerController {
       private static final Logger logger = LoggerFactory.getLogger(CarSellPartnerController.class);

       @Autowired
       CarSellPartnerDubboService carSellPartnerDubboService;

       @GetMapping("/queryCarSellPartner")
       @ApiOperation(value = "查询分页")
       public ApiResult queryCarSellPartner(CarSellPartnerQueryReqVO carSellPartnerVO, Integer pageNum, Integer pageSize) throws Exception {
           return ResponseUtil.ok(carSellPartnerDubboService.findPageByVO(carSellPartnerVO, pageNum, pageSize));
       }


     @GetMapping("/queryCarSellPartnerBySingle")
     @ApiOperation(value = "读取单个")
     public ApiResult queryCarSellPartnerBySingle(CarSellPartnerQueryReqVO carSellPartnerVO, @CurrentUser LoginInfo loginInfo) throws Exception {
         return ResponseUtil.ok(carSellPartnerDubboService.getById(carSellPartnerVO.getSellId()));
     }

     @PostMapping("/save")
     @ApiOperation(value = "保存信息")
     public ApiResult save(@RequestBody CarSellPartnerSaveReqVO carSellPartnerVO, @CurrentUser LoginInfo loginInfo) throws Exception {
        return carSellPartnerDubboService.saveCas(carSellPartnerVO);
     }

    /**
     * 设置APP放行状态
     * @param vo
     * @return
     */
     @PostMapping("/setAppStatus")
     @ApiOperation(value="设置App放行状态 1启用 0禁用")
     public ApiResult setAppStatus(@RequestBody CarSellPartnerSetAppStatusReqVO vo){
         carSellPartnerDubboService.setAppStatus(vo);
         return ResponseUtil.ok("success");
     }
}
